home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / MAKECH.ARJ / MAKECH.DOC next >
Text File  |  1992-04-23  |  3KB  |  91 lines

  1. MakeCh - Clipper5 supporting utility
  2. ======================================
  3.  
  4. Placed in public domain by the author: John Lucas
  5.                                        Toronto, CANADA
  6.                                        CIS 73700,1074
  7.  
  8. I hope other developers find this program useful.  However John Lucas
  9. takes no responsibility for anything at all.  You get what you paid for.
  10.  
  11. =========================================================================
  12.  
  13. For Clipper 5.0 developers the program builds and maintains an
  14. application specific header file containing definitions of each
  15. field.  This header file is used with the Scatter and Gather user
  16. functions distributed with this program.
  17.  
  18. To run the program simply type MakeCh at a DOS prompt.
  19.  
  20. The program will request the drive and path of your project
  21. directory and the path and name of an application specific header file
  22.  
  23. The following example shows how the header file works in conjunction
  24. with the Scatter and Gather user functions:
  25.  
  26. Assume a Customer file has been created with three fields:-
  27.  
  28.             CustNum     Numeric     3
  29.             CustName    Character  20
  30.             CustAct     Logical     1
  31.  
  32. MakeCh will create a header file (Cust.CH in this example) containing
  33.  
  34.         #Define mCustNum        aCustomer[1]
  35.         #Define mCustName       aCustomer[2]
  36.         #Define mCustAct        aCustomer[3]
  37.  
  38. The header file will also contain the definitions for the Scatter and
  39. Gather commands.
  40.  
  41. Note: If you have an existing application header file MakeCh will add
  42. these definitions to its end.  Subsequent runs of MakeCh will leave
  43. your original header code intact only replacing the MakeCh defintions.
  44.  
  45. Code logic to update a record in the customer file will contain:
  46.  
  47.     #Include "Inkey.ch"
  48.     #Include "Cust.ch"
  49.  
  50.     Local aCustomer                // Array to hold fields
  51.  
  52.     Use Customer
  53.     Scatter to aCustomer           // Fill array from current record
  54.  
  55.     @ 10,10 say "Customer number"       get mCustNum      Picture pCustNum
  56.     @ 12,10 say "           Name"       get mCustName     Picture pCustName
  57.     @ 14,10 say "Customer active"       get mCustActive   Picture pCustAct
  58.                                             ^
  59.                                             |
  60.                                             ------  Get into array
  61.     read
  62.  
  63.     if !lastkey() = K_Esc
  64.         Gather from aCustomer       // Replace from array elements
  65.     endif
  66.  
  67.  
  68. To add a new customer record use
  69.  
  70.             Scatter to aCustomer New
  71.  
  72. This will fill the array with the approriate empty values.  In this
  73. example 0, space(20) and .F.
  74.  
  75. NOTE: the local definition of aCustomer.  This must be an "a" followed by
  76.       the data base name to match the #defines for the fields.
  77.  
  78. To use scatter and gather from another work area code:
  79.  
  80.         Scatter to aCustomer from Customer
  81.  
  82.         Gather from aCustomer to Customer
  83.  
  84. WARNING Duplicate field name will give error messages at compile time.
  85.         e.g. if CustNum is in both Customer.dbf and Invoice.dbf
  86.              mCustNum will be defined as aCustomer[1] and as aInvoice[x]
  87.  
  88. A CHALLENGE Any bright minds come up with a better way to handle this?
  89. =========== Also I don't really like having to code the Local aALIAS
  90.  
  91.